import boto
import boto.s3.connection
from boto.s3.key import Key
from multiprocessing import Pool

conn = boto.connect_s3(
            aws_access_key_id = '4C3Z7YH7CCN4MV7MZBUM',
            aws_secret_access_key = 'ASuvrSgfIearbU2VnYnNleecgLstRBHw1B8lE7QZ',
            host = 's3.ceph.com',is_secure=False,
            calling_format = boto.s3.connection.OrdinaryCallingFormat())

bucket = conn.get_bucket('speedtest') 
print 'Connecting Bucket:%s'%bucket.name
'''
for key in bucket:
	print key.name
	key.delete()
print 'Remove Bucket:%s'%bucket.name
bucket.delete()
'''
def cleandata(bucket):
	pro_num = 100
	p = Pool(processes=pro_num)
	for key in bucket:
	    print key.name
	    p.apply_async(key.delete(),args=())
	p.close()
	p.join()


##########
print 'Current Buckets'
for bucket in conn.get_all_buckets():
        print "{name}\t{created}".format(
                name = bucket.name,
                created = bucket.creation_date,
        )
cleandata(bucket)

'''
for bucket in conn:
    for key in bucket:
        print key.name
	key.delete()
    bucket.delete()
'''
